Ext.define('App.controller.HomeController', {
    extend: 'Ext.app.Controller',
    
    config: {
        refs: {
            //            pnlLoading: "#pnlLoading",
            mainPanel: "#mainPanel"
        },
        
        control: {
            //            pnlLoading: {
            //                show: "onPnlLoadingShow"
            //            },
            mainPanel: {
                show: "onMainPanelShow"
            }
        }
    },
    
    
    //	onPnlLoadingShow: function(component, options) {
    //	    LoadingHomeContent();
    //	},
    
    
    onMainPanelShow: function(component, options){
        Ext.data.JsonP.request({
            url: config.url + 'findHomeImage.action',
            timeout: 4000,
            callback: "callback",
            success: function(response){
                var root = response.root;
                for (var i = 0; i < root.length; i++) {
                    var img = new Ext.Img({
					   html:	       '<div class="photo">' +
                    		           '<span>'+ root[i].title +'</span>'+
                    	               '<img src="/' + root[i].image + '" alt=""/>' +
						       '</div>',
						cls: "my-carousel-item"
							   
                    });
                    $i('homeCarousel').add(img);
                }
                var me = $i('homeCarousel');
                var cards = me.items.items;//获得carousel中的items的个数
                var j = 0;
                setInterval(function(){
                    me.setActiveItem(cards[(j++) % me.items.getCount()], {
                        type: 'slide',
                        direction: 'left'
                    });
                }, 3500);
                
            },
            failure: function(){
            
            }
        });
    }
    
    
    
});
